<fieldset>
    <legend>条件搜索</legend>
    <form class="layui-form layui-form-pane form-search" action="{:request()->url()}" onsubmit="return false" method="get" autocomplete="off">
        <div class="layui-form-item layui-inline">
            <label class="layui-form-label">培训名称</label>
            <div class="layui-input-inline" style="width:140px;">
                <input name="class_name" value="{:input('class_name','')}" placeholder="请输入班级名称" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item layui-inline">
            <label class="layui-form-label">学员姓名</label>
            <div class="layui-input-inline" style="width:140px;">
                <input name="name" value="{:input('name','')}" placeholder="请输入学员姓名" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item layui-inline">
            <label class="layui-form-label">发证日期</label>
            <div class="layui-input-inline" style="width:140px;">
                <input maxlength="64" value="{:input('time_span','')}" data-date-range placeholder="请在这里输入报名时间" name='time_span' class="layui-input">
            </div>
        </div>

        <div class="layui-form-item layui-inline">
            <label class="layui-form-label">市州</label>
            <div class="layui-input-inline">
                <select class="layui-select" name="city" >
                    <option value="">-- 全部市州 --</option>
                    {foreach $CITY_OPTION as $k=>$v}
                    {if $v eq $city}
                    <option selected value="{$v}">{$v}</option>
                    {else}
                    <option value="{$v}">{$v}</option>
                    {/if}
                    {/foreach}
                </select>
            </div>
        </div>
        <div class="block">

            <div class="layui-form-item layui-inline">
                <label class="layui-form-label">身份证号</label>
                <div class="layui-input-inline" style="width:140px;">
                    <input name="idno" value="{:input('idno','')}" placeholder="请输入身份证" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item layui-inline">
                <label class="layui-form-label">单位名称</label>
                <div class="layui-input-inline" style="width:140px;">
                    <input name="company" value="{:input('company','')}" placeholder="请输入单位名称" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item layui-inline">
                <button class="layui-btn layui-btn-primary"><i class="layui-icon">&#xe615;</i> 搜 索</button>
            </div>
            <div class="layui-form-item layui-inline">
                <button name="btn-export" class="layui-btn margin-left-10" type="button">
                    <i class="layui-icon layui-icon-export"></i>
                    <span> 导出档案信息</span>
                </button>
            </div>
            <div class="layui-form-item layui-inline">
                <button name="btn-import" data-title="上传文件" data-file="btn"  data-field="upload-cert"
                        class="layui-btn margin-left-10" type="button">
                    <i class="fa fa-cloud-upload"> </i>
                    <span> 导入档案</span>
                </button>
                <a target="_blank" style="position:absolute;right:6px;top:29px;"
                   href="/excel/educert.xlsx">下载模板文件</a>
            </div>
            <div class="layui-form-item layui-inline">
                <button name="btn-import" data-title="上传文件" data-file="btn"  data-field="upload-cert-old"
                        class="layui-btn margin-left-10" type="button">
                    <i class="fa fa-cloud-upload"> </i>
                    <span> 导入历史档案</span>
                </button>
                <a target="_blank" style="position:absolute;right:6px;top:29px;"
                   href="/excel/educertold.xlsx">下载模板文件</a>
            </div>
        </div>
    </form>
    <input type="hidden" name="upload-cert" value="" />
    <input type="hidden" name="upload-cert-old" value="" />
</fieldset>

<script>window.form.render()</script>
<script>
    $("button[name=btn-export]").click(function () {
        location.href = '/cms/educert/export.html?'+$("form.form-search").serialize();

    });
    $("input[name=upload-cert]").change(function () {
        var url = $(this).val();
        $.ajax({
            type : "POST",
            url : "/cms/educert/import.html",
            data : {"url":url},
            success : function(result) {
                console.log(result);
                if(result.code==1){
                    location.reload();
                    layer.msg(result.info, {
                        time: 3000, //20s后自动关闭
                    });
                }else{
                    layer.msg(result.info);
                }
            },
            error : function(e){
                layer.msg(e.responseText, {
                    time: 5000, //20s后自动关闭
                });
            }
        });
    });
    $("input[name=upload-cert-old]").change(function () {
        var url = $(this).val();
        $.ajax({
            type : "POST",
            url : "/cms/educert/importOld.html",
            data : {"url":url},
            success : function(result) {
                console.log(result);
                if(result.code==1){
                    location.reload();
                    layer.msg(result.info, {
                        time: 3000, //20s后自动关闭
                    });
                }else{
                    layer.msg(result.info);
                }
            },
            error : function(e){
                layer.msg(e.responseText, {
                    time: 5000, //20s后自动关闭
                });
            }
        });
    });
</script>